
/**
 * 
 * @param {{id:'',pid:''}} list 
 * @param {'第一级权限的 pid'} id 
 * @returns {{children:'子节点'}} tree
 */
export function listToTree(list, id) {
  let tree = []
  list.forEach(item => {
    if (item.pid == id) {
      tree.push(item)
      item.children = listToTree(list, item.id)
    }
  })
  return tree
}